<%@ include file="/include/taglib.jsp"%>

<c:set var="itemLevel" value="1" scope="request"/>
<c:forEach var="itemField" items="${item.fields}">
	<c:set var="itemField" value="${itemField}" scope="request"/>
	<c:set var="item" value="${item}" scope="request"/>
	<% pageContext.setAttribute("itemField" + pageContext.getAttribute("itemLevel", PageContext.REQUEST_SCOPE), pageContext.getAttribute("itemField", PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE); %>
	<% pageContext.setAttribute("item" + pageContext.getAttribute("itemLevel", PageContext.REQUEST_SCOPE), pageContext.getAttribute("item", PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE); %>
	<c:choose>
		<c:when test="${not empty user and itemField.wysiwyg}">
			<c:set var="editableClass" value="wysiwyg" scope="request"/>
		</c:when>
		<c:when test="${not empty user and itemField.textarea}">
			<c:set var="editableClass" value="editableTextarea" scope="request"/>
		</c:when>
		<c:when test="${not empty user}">
			<c:set var="editableClass" value="editable" scope="request"/>
		</c:when>
		<c:otherwise>
			<c:set var="editableClass" value="" scope="request"/>
		</c:otherwise>
	</c:choose>
	<c:set var="itemLevel" value="${itemLevel + 1}" scope="request"/>
	<jsp:include page="/fragment/ItemField.jsp"/>
	<c:set var="itemLevel" value="${itemLevel - 1}" scope="request"/>
	<% pageContext.setAttribute("itemField", pageContext.getAttribute("itemField" + pageContext.getAttribute("itemLevel", PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE); %>
	<% pageContext.setAttribute("item", pageContext.getAttribute("item" + pageContext.getAttribute("itemLevel", PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE), PageContext.REQUEST_SCOPE); %>
</c:forEach>
